package src.edu.wayne.cs.csc4110.hw6.implementations.stateMachine;

import javax.swing.JPanel;

import src.edu.wayne.cs.csc4110.hw6.interfaces.FrameWork;
import src.edu.wayne.cs.csc4110.hw6.interfaces.State;

public class StateMachine implements State {
	private State loggedInState;
	private State registerState;
	private State friendsState;
	private State privateChatState;
	private State playGameState;
	private State notLoggedInState;
	private State addUserState;
	private State changeToNextUserState;
	private StateMachineFrame displayFrame;
	private FrameWork frameWork;

	private State state;
	
	public StateMachine(FrameWork frameWorkImpl) {

		this.frameWork = frameWorkImpl;
		displayFrame = StateMachineFrame.getStateMachineFrame();
		loggedInState = new LoggedInState(this);
		registerState = new RegisterState(this);
		friendsState = new FriendsState(this);
		privateChatState = new PrivateChatState(this);
		playGameState = new PlayGameState(this);
		notLoggedInState = new NotLoggedInState(this);
		addUserState = new AddUserState(this);
		changeToNextUserState = new ChangeToNextUserState(this);
		this.state = notLoggedInState;
		
	}
	
	public void setState(State state)
	{
		this.state = state;
	}

	@Override
	public void goToLoggedInState() {
		state.goToLoggedInState();
	}
	
	@Override
	public void goToRegisterState() {
		state.goToRegisterState(); 

	}

	@Override
	public void goToFriendsState() {
		state.goToFriendsState();
	}

	@Override
	public void goToPrivateChatState() {
		state.goToPrivateChatState();

	}

	@Override
	public void goToPlayGameState() {
		state.goToPlayGameState();

	}

	@Override
	public void goToNotLoggedInState() {
		state.goToNotLoggedInState();		
	}
	
	@Override
	public void goToAddUserState() {
		state.goToAddUserState();
	}

	public FrameWork getFrameWork(){
		return this.frameWork;
	}
	
	public State getLoggedInState(){return loggedInState;}
	public State getRegisterState(){return registerState;}
	public State getFriendsState(){return friendsState;}
	public State getPrivateChatState(){return privateChatState;}
	public State getPlayGameState(){return playGameState;}
	public State getNotLoggedInState(){return notLoggedInState;}
	public State getAddUserState(){return addUserState;}
	public State getChangeToNextUserState(){return changeToNextUserState;}

	public StateMachineFrame getDisplayFrame() {
		return this.displayFrame;
	}

	public void setDisplayFrame(StateMachineFrame displayFrame) {
		this.displayFrame = displayFrame;
	}
	
	public void setDisplayPanel(JPanel newPanel, String newTitle){
		this.displayFrame.setCurrentPanel(newPanel, newTitle);
	}

	@Override
	public void goToChangeToNextUserState() {
		state.goToChangeToNextUserState();	
	}


}
